/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.ssau.berlin.jsf.beans;

import javax.ejb.EJB;
import ru.ssau.berlin.ejb.facade.UniFacadeLocal;
import ru.ssau.berlin.entity.AttributeType;
import ru.ssau.berlin.framework.AttributeTypeEnum;
import ru.ssau.berlin.jsf.util.FacesApplication;

/**
 *
 * @author Caesar
 */

public class AdminController {

    @EJB
    private UniFacadeLocal uniFacade;

    private FacesApplication application = FacesApplication.getInstance();

    /** Creates a new instance of AdminController */
    public AdminController() {
    }

    public String fillAttributeTypes() {
        for (AttributeTypeEnum type: AttributeTypeEnum.values()) {
            if (uniFacade.findAttributeType(type.toString()) == null) {
                AttributeType newType = new AttributeType();
                newType.setName(type.toString());
                uniFacade.createAttributeType(newType);
            }
        }
        return application.getNavigator().stayHere();
    }

}
